package com.sdktest;

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import cn.com.mma.mobile.tracking.api.Countly;

/**
 * 此工程是为SDK开发者提供
 * @author lincoln
 * 
 */
public class MainActivity extends Activity {
	/**
	 * sdkconfig.xml配置文件服务器存放地址
	 */
	public static final String CONFIG_URL = "http://ratwu.com/sdkconfig.xmldddd";
	/**
	 * 点击监测地址
	 */
	public static final String TEST_TRACKING_URL = "http://vxyz.admaster.com.cn/v/a17298,b65439305,c3194,i0,m201";

	private Countly mCountly;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_main);

		mCountly = Countly.sharedInstance();
		/**
		 * 初始化SDK
		 */
		mCountly.setLogState(true);
		mCountly.init(this, CONFIG_URL);
		
		
	}

	public void sendMsg(View view) {
		mCountly.onClick(TEST_TRACKING_URL);
		
//		runOnUiThread(new Runnable() {
//			int count = 0;
//
//			@Override
//			public void run() {
//				while (count < 5) {
//					try {
//						Thread.sleep(1000);
//					} catch (InterruptedException e) {
//						e.printStackTrace();
//					}
//					findViewById(R.id.btn_send).performClick();
//					count++;
//					Logger.d("count:"+count);
//				}
//			}
//		});
	}
	
	public void stopSendMsg(View view){
		mCountly.stopCurrentSendThread();
	}

	public void clearErrorList(View view) {
		mCountly.clearErrorList();
	}

	public void clearAllList(View view) {
		mCountly.clearAll();
		mCountly.stopListenerLocation(this);
	}

}
